﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace WPFSqlSugarDemo.Converter
{
    public class IntToGenderConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
           int.TryParse(value.ToString(),out int gender);
            if (gender == 0)
            {
                return "女";
            }
            else
            {
                return "男";
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if((string)value == "女")
            {
                return 0;
            }
            else
            {
                return 1;
            }
        }
    }
}
